package com.dries.security.core.social.qq.connect;

import com.dries.security.core.social.qq.api.QQ;
import com.dries.security.core.social.qq.api.QQImpl;
import org.springframework.social.oauth2.AbstractOAuth2ServiceProvider;

/**
 * @Description:
 * @Author ZSY
 * @createTime 2020/9/15 16:40
 */
public class QQServiceProvider extends AbstractOAuth2ServiceProvider<QQ> {

    private final String appId;

    // 1.获取授权码Code
    private static final String QQ_URL_AUTHORIZE = "https://graph.qq.com/oauth2.0/authorize";
    // 2.获取accessToken
    private static final String QQ_URL_ACCESS_TOKEN = "https://graph.qq.com/oauth2.0/token";

    public QQServiceProvider(String appId, String appSecret) {
        super(new QQOAuth2Template(appId, appSecret, QQ_URL_AUTHORIZE, QQ_URL_ACCESS_TOKEN));
        this.appId = appId;
    }

    @Override
    public QQ getApi(String accessToken) {
        return new QQImpl(accessToken, appId);
    }
}
